One of the most challenging tasks in the process of creating a computer program is the step of testing the program to ensure that it is free of errors. Generally, testing a program involves executing the program, and inspecting the program output to ensure that it conforms with the desired or expected output.
It has become common practice to test a program by running it through a test suite in which the program is executed a large number of times, using different input data each time, so that as many of the program options as possible are exercised. A problem that frequently arises during the use of such test suites is that a complex program will often include sections of program code that are rarely executed. For example, a program may include a code section that is designed to handle an error condition that occurs only under unusual circumstances. It is possible that a given test suite will fail to produce such circumstances, and that the code section in question will therefore not be tested.
One possible approach to alleviate this problem would be to design a test coverage program to determine if any lines of a target program (i.e., the program to be tested) have not been executed during a given test suite. By examining the output of such a test coverage program, it would be possible to determine whether the test suite has failed to cause the execution of any code sections. Unfortunately, the only practical method of keeping track of which lines of program code have been executed is to run the target program in "step" mode. In such a mode, each time that a target program instruction is executed, execution is temporarily halted, and control is passed to the test coverage program that records the execution of that particular instruction. Control is then returned to the target program, the target program executes the next instruction, then transfers control back to the test coverage program, etc.
While the single-step process described above can provide the required information concerning which target program instructions have been executed, the process of running the target program in step mode would be very slow. Since a given test suite will often require a large number of executions of the target program with various input data, the total amount of time required to test a program in this manner would be extremely long. For this reason, it would be a significant advantage to provide a test coverage technique that is capable of faster operation.